#ifndef TYPEDIALOG_H
#define TYPEDIALOG_H

#include "AbstractMappingWindow.h"

class AbstractMappingWindow;
class WOP_Entry;
class QGraphicsRectItem;
class TypeManager;
class xMappingTree;
class NodeOutPort;

class TypeDialog : public AbstractMappingWindow {
	Q_OBJECT

public:
	TypeDialog( QWidget * parent );
	virtual ~TypeDialog();
	void setCurrentEntry( WOP_Entry* );
	WOP_Entry* currentEntry();
	void createSubTab(std::string, WOP_Entry*);
	QGraphicsRectItem* getForeachRect();
	xMappingTree * getMappingTree() const;
	bool isFinished() const;

public slots:
	void saveMDS();
	void saveMDS(QString);
	void loadMDS();
	void loadMDS(QString);
	void clickApply();
	void onContextMenu( WOP_Entry * entry, NodeOutPort * outPort );
	void onAddTM();

	// FIXME: changed access from base class
	void closeEvent ( QCloseEvent* );

signals:
	void finished();

private:
	TypeManager* _currentManager;
	WOP_Entry* _currentEntry;
	QAction *_saveMDSFile;
	QAction *_loadMDSFile;
	QGraphicsRectItem *_foreachRect;
	xMappingTree * _mapping;
	QMenu * contextMenu_;
	WOP_Entry * currentMenuEntry_;
	NodeOutPort * currentOutPort_;
	bool finished_;

	void initMenuBar();
	void initEntry();
	void createOtherWidget();
	void initCanvas();
	void createForeachRect();
	AbstractManager* initManager();
//	NodeItem * addMappingNode( WOP_Entry * en );
};

#endif
